/*
    Heart of Gold engine management system
    Copyright (C) 2004 Heart of Gold development team

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/**
 * @author Greg Feigenson
 * @author Ryan Higgins
 * @version RC1
 * @since 2
 * 
 * The "main menu" of the application. Only page that
 * has the logo on it for HOG - if you want to, feel free
 * to add the logo elsewhere as an ImageIcon.
 */

package com.heartOfGold.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class MainWindow extends JPanel implements ActionListener {
    public MainWindow(final String[] labels) {
        /* Logo setup */
        setLayout(new BorderLayout());
        hogLogo = new JLabel(new ImageIcon("HOG_logo.png"));

        /* Border */
        setBorder(BorderFactory.createTitledBorder("Welcome to Heart of Gold"));

        /* Add Logo */
        add(hogLogo, BorderLayout.NORTH);

        /* Setup button panel */
        buttons = new JButton[labels.length];
        for (int i = 0; i < labels.length; i++) {
            buttons[i] = new JButton(labels[i]);
            buttonPanel.add(buttons[i]);
            (buttons[i]).addActionListener(this);
        }

        add(buttonPanel, BorderLayout.CENTER);
    }

    public final void actionPerformed(final ActionEvent ae) {
        String command = ae.getActionCommand();

        if (command.equals("Quit")) {
            System.exit(0);
        }

        if (!Ui.switchScreen(command)) {
            JOptionPane.showMessageDialog(this,
                    "This function is not yet implemented", "Not Implemented",
                    JOptionPane.INFORMATION_MESSAGE);
        }

    }

    /* Datamembers */
    //TODO set data members private create accessors as needed.
    JButton[] buttons;
    JPanel buttonPanel = new JPanel(new FlowLayout());
    JLabel hogLogo;
}
